public class Main {
    public static void main(String[] args) {
        Chessman chess = new Chessman("车", 1, 1);
        MementoCaretaker caretaker = new MementoCaretaker();

        display(chess);
        caretaker.saveMemento(chess.save());

        chess.setY(4);
        display(chess);
        caretaker.saveMemento(chess.save());

        chess.setX(5);
        display(chess);

        System.out.println("**********悔棋**********");
        chess.restore(caretaker.retrieveMemento()); // 恢复到上一个状态
        display(chess);

        System.out.println("**********悔棋**********");
        chess.restore(caretaker.retrieveMemento()); // 再次恢复到上一个状态
        display(chess);
    }
    public static void display(Chessman chess) {
        System.out.println("棋子" + chess.getLabel() + "当前位置：" + "第" + chess.getX() + "行，第" + chess.getY() + "列");
    }
}
